#define _CRT_SECURE_NO_WARNINGS

#include "Sort.h"

void InsertSortTest()
{
	int arr[] = { 6,3,8,1,9,2,5,7,4 };
	int sz = sizeof(arr) / sizeof(arr[0]);

	InsertSort(arr, sz);
	ArrayPrint(arr, sz);
}

void QuickSortTest()
{
	int arr[] = { 6,3,8,1,9,2,5,7,44,2,13,1,31,13,1,3,3,2 };
	int sz = sizeof(arr) / sizeof(arr[0]);

	QuickSort(arr, 0, sz - 1);
	ArrayPrint(arr, sz);
}

void QuickSortNonRTest()
{
	int arr[] = { 6,3,8,1,9,2,5,7,44,2,13,1,31,13,1,3,3,2 };
	int sz = sizeof(arr) / sizeof(arr[0]);

	QuickSortNonR(arr, 0, sz - 1);
	ArrayPrint(arr, sz);
}

void MergeSortTest()
{
	int arr[] = { 6,3,8,1,9,2,5,7,44,2,13,1,31,13,1,3,3,2 };
	int sz = sizeof(arr) / sizeof(arr[0]);

	int* tmp = (int*)malloc(sizeof(int) * sz);
	if (tmp == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}

	MergeSort(arr, 0, sz - 1, tmp);
	ArrayPrint(arr, sz);
}

int main()
{
	InsertSortTest();
	QuickSortTest();
	QuickSortNonRTest();
	MergeSortTest();

	return 0;
}